<?php 
require_once("soap/nusoap.php");
require_once("config.php");
$ns="http://store8x.com/webser/";
//$ns="http://localhost/vfun/";
$server = new soap_server();  
$server->configureWSDL('Service',$ns);
$server->wsdl->schemaTargetNamespace=$ns;  
$server->soap_defencoding = 'UTF-8'; 
$server->register('receiveMO',
	array(	'commandcode' => 'xsd:string',  //EX: WF, WORLD
    		'serviceid' => 'xsd:string', // Số dịch vụ (6x76)
    		'userid'=> 'xsd:string', //84902171891
    		'message'=> 'xsd:string', //ACC pass,KD nje
    		'requestid'=> 'xsd:string',//ID MO: randomcode: 298963647
    		'username'=> 'xsd:string', //authentication
    		'password'=> 'xsd:string'),//authentication	
	 array('result' => 'xsd:string'),  
		    $ns,                                                  
		    "$ns#receiveMO", 
		    'rpc',                        
		    'encoded',                    
		    'get MO'      
		    );

function receiveMO($commandcode,$serviceid,$userid,$message,$requestid,$username,$password){
return new soapval('return','xsd:string',getMO($commandcode,$serviceid,$userid,$message,$requestid,$username,$password));
}

if ( !isset( $HTTP_RAW_POST_DATA ) ) $HTTP_RAW_POST_DATA =file_get_contents( 'php://input' );
$server->service($HTTP_RAW_POST_DATA); 

function getMO($commandcode,$serviceid,$userid,$message,$requestid,$username,$password) {
//123.30.188.54
	if($username == "lemon829" && $password=="lemon.123!@#8x29"){  
				//if(check_phone_time($userid) == true && checkphonetoday($userid)==true ){
					if(addmo($commandcode,$serviceid,$userid,$message,$requestid) == true){
						addbalance($userid,15);
						//$messageType = 0: khong tru cuoc, 1 tru cuoc 
						//$contentType = 0
						//if(resendmt($commandcode,$serviceid,$userid,$message,"1","0",$requestid)==true){
						//	return $userid." da nap 15 xu de xem phim thanh cong !"; 
						//}
						//resendmt($commandcode,$serviceid,$userid,$message,"1","0",$requestid);
						$wsdl= 'http://123.30.188.54/mt-services/MTService?WSDL';  
			 			$client=new nusoap_client($wsdl, array('wsdl'));  
						$param=array('userId' => $userid,  
		    			'serviceId' => $serviceid,  
		    			'commandCode'=> $commandcode, 
		    			'info'=> base64_encode($userid.' da nap 15 xu de xem phim thanh cong !'),   
		    			'messageType'=> '1', 
		    			'contentType'=> '0',
						'sRequestId'=>$requestid);
						$client->setCredentials('store8x', 'store847jdhhgsldjfg38x'); 
						$result = $client->call('sendMTPhp', $param);
			 			return "0|TK cua ban da nap 15 xu http://video.store8x.com - tai them cac ung dung khac truy cap http://store8x.com/app";
					} else{
						return "1|Nap xu khong thanh cong";
					}
				//}else{
				//	return "-3";
				//}  
	}else {
		return "-4";
	}
} 




?>
